package cn.itsource.hbc.product.service.impl;

import cn.itsource.basic.query.BaseQuery;
import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.hbc.pet.mapper.PetDetailMapper;
import cn.itsource.hbc.product.domain.Product;
import cn.itsource.hbc.product.domain.ProductDetail;
import cn.itsource.hbc.product.mapper.ProductDetailMapper;
import cn.itsource.hbc.product.mapper.ProductMapper;
import cn.itsource.hbc.product.service.IProductService;
import cn.itsource.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductServiceImpl extends BaseServiceImpl<Product> implements IProductService {

    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ProductDetailMapper productDetailMapper;



    @Override
    public void save(Product product) {

        productMapper.save(product);

        ProductDetail detail = product.getDetail();
        detail.setProduct_id(product.getId());
        productDetailMapper.save(detail);
    }

    @Override
    public void update(Product product) {
        productMapper.update(product);

        ProductDetail detail = product.getDetail();
        detail.setProduct_id(product.getId());
        productDetailMapper.update(detail);
    }

    @Override
    public void onSale(Long[] ids) {
        productMapper.onSale(ids);
    }

    @Override
    public void offSale(Long[] ids) {
        productMapper.offSale(ids);
    }
}
